import React, { Component } from 'react'
import {connect} from "react-redux" // 将组件跟仓库进行关联的库,接收两个参数，第一个参数中有两个函数，第二个参数是咱们的组件
import * as action from "../action/index.js"
import { bindActionCreators} from "redux" // 是用来合并抽离出去的action的
// 在类组件中不能使用hooks
class Classfily extends Component {
   componentDidMount() {
       console.log(this.props,1111);
       this.props.getList()
        
   }
  render() {
    return (
      <div>
          {
              this.props.arr && this.props.arr.length ? this.props.arr.map((item,index)=>{
                return <div>
                     {item.Name}
                 </div>
              }):"暂无数据"
          }
      </div>
    )
  }
}
let mapStateToprops = (state)=>{ // 将仓库中的数据赋值给组件中的props
       console.log(state,"state");
        return {
            ...state.shopReducer
        }
}
let mapDispatchToprops = (dispatch)=>bindActionCreators(action,dispatch)
export default connect(mapStateToprops,mapDispatchToprops)(Classfily)